function userData() {
    $.ajax({
        url: "findUserByUserID_1",
        type: "POST",
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        success: function (data) {
            var code = '';
            if (data.code = 200) {
                code += "<div class=\"myaccount-dashboard light-shadow-bg\">\n" +
                    "                                <div class=\"light-box-content\">\n" +
                    "                                    <div class=\"media-box\">\n" +
                    "                                        <div class=\"item-img\">\n" +
                    "                                            <img src=\"user/media/figure/avatar.jpg\" alt=\"avatar\">\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"item-content\">\n" +
                    "                                            <h3 class=\"item-title\">" + data.user_List[0].userNickname + "</h3>\n" +
                    "                                            <div class=\"item-email\"><span>Email: </span>" + data.user_List[0].userEmail + "</div>\n" +
                    "                                        </div>\n" +
                    "                                    </div>\n" +
                    "                                    <div class=\"static-report\">\n" +
                    "                                        <h3 class=\"report-title\">个人简介</h3>\n" +
                    "                                        <div class=\"report-list\">\n" +
                    "                                            <div class=\"report-item\">\n" +
                    "                                                <label>用户账号：</label>\n" +
                    "                                                <div class=\"item-value\">" + data.user_List[0].userLoginName + "</div>\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"report-list\">\n" +
                    "                                            <div class=\"report-item\">\n" +
                    "                                                <label>用户名称：</label>\n" +
                    "                                                <div class=\"item-value\">" + data.user_List[0].userName + "</div>\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"report-list\">\n" +
                    "                                            <div class=\"report-item\">\n" +
                    "                                                <label>用户性别：</label>\n" +
                    "                                                <div class=\"item-value\">" + data.user_List[0].userSex + "</div>\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"report-list\">\n" +
                    "                                            <div class=\"report-item\">\n" +
                    "                                                <label>用户年龄：</label>\n" +
                    "                                                <div class=\"item-value\">" + data.user_List[0].userAge + "</div>\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"report-list\">\n" +
                    "                                            <div class=\"report-item\">\n" +
                    "                                                <label>出生日期：</label>\n" +
                    "                                                <div class=\"item-value\">" + data.user_List[0].userDateOfBirth + "</div>\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"report-list\">\n" +
                    "                                            <div class=\"report-item\">\n" +
                    "                                                <label>联系方式：</label>\n" +
                    "                                                <div class=\"item-value\">" + data.user_List[0].userPhone + "</div>\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"report-list\">\n" +
                    "                                            <div class=\"report-item\">\n" +
                    "                                                <label>家庭住址：</label>\n" +
                    "                                                <div class=\"item-value\">" + data.user_List[0].userAddress + "</div>\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"report-list\" id='price'>\n" +

                    "                                        </div>\n" +
                    "                                    </div>\n" +
                    "                                </div>\n" +
                    "                            </div>";
            }


            $("#dashboard").html("");
            $("#dashboard").append(code);
            findMoneyBySumUserMoneyPrice();
        }

    });
}

function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month;
    return currentdate;
}

function findMoneyBySumUserMoneyPrice() {
    var date = getNowFormatDate();
    var data = {
        "userMoneyDate": date
    };
    $.ajax({
        url: "findMoneyBySumUserMoneyPrice",
        type: "POST",
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        data: JSON.stringify(data),
        success: function (data) {
            var code = '';
            if (data.code == 500) {
                code += "                                            <div class=\"report-item\">\n" +
                    "                                                <label>月份收入：</label>\n" +
                    "                                                <div class=\"item-value\" style='color: red'>0元</div>\n" +
                    "                                            </div>";
            } else {
                code += "                                            <div class=\"report-item\">\n" +
                    "                                                <label>月份收入：</label>\n" +
                    "                                                <div class=\"item-value\" style='color: red'>" + data.money_list[0].sumUserMoneyPrice + "元</div>\n" +
                    "                                            </div>";
            }
            $("#price").html("");
            $("#price").append(code);
        }
    });
}

$(function () {
    var DATA = '';
    $.ajax({
        url: "JudgeLogin_3",
        type: "POST",
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        success: function (data) {
            if (data.code == 500) {
                DATA += " <li class=\"header-btn\">\n" +
                    "                                    <a href=\"web-login.html\" class=\"item-btn\"><i class=\"fas fa-plus\"></i>登录</a>\n" +
                    "                                </li>"
                Swal.fire("温馨提示", "请先登录", "warning");
                window.location.href = "web-user-404.html";
            } else {
                DATA += " <li class=\"header-login-icon\">\n" +
                    "                                    <a href=\"web-user-account.html\" class=\"color-light\" data-toggle=\"tooltip\"\n" +
                    "                                       data-placement=\"top\" title=\"Login/Register\">\n" +
                    "                                        <i class=\"far fa-user\">我的</i>\n" +
                    "                                    </a>\n" +
                    "                                </li>\n" +
                    "                                <li class=\"header-btn\">\n" +
                    "                                    <a  onclick='tuichu1()' class=\"item-btn\"><i class=\"fas fa-plus\"></i>退出</a>\n" +
                    "                                </li>";
                userData();
            }
            $("#userData").html("");
            $("#userData").append(DATA);
        }
    });
});